package me.zhengjie.domain;

import lombok.RequiredArgsConstructor;
import me.zhengjie.dto.sqlServer.PlcUnbinding;
import me.zhengjie.repository.PlcInBoundRepository;
import me.zhengjie.repository.PlcOutBoundRepository;
import me.zhengjie.repository.PlcUnbindingRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@RequiredArgsConstructor
public class PlcService {

    private final PlcInBoundRepository plcInBoundRepository;
    private final PlcOutBoundRepository plcOutBoundRepository;
    private final PlcUnbindingRepository plcUnbindingRepository;

    @Transactional
    public void updateUnbindingStationPalletCode(String palletCode, int id){
        plcUnbindingRepository.updatePalletCodeById(palletCode,id);
    }

    public PlcUnbinding getUnbindingStationPalletCode(String palletCode){
        return plcUnbindingRepository.findPlcUnbindingByContent(palletCode);
    }

    public PlcUnbinding getUnbindingStationByIp(String ip){
        return plcUnbindingRepository.findPlcUnbindingByIp(ip);
    }

    @Transactional
    public void updateUnbindingStationByIp(String palletCode, String ip){
        plcUnbindingRepository.updatePalletCodeByIp(palletCode,ip);
    }


}
